<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title>OnlineColock</title>
		<script src="js/vue.js" type="text/javascript" charset="utf-8"></script>
	</head>
	<body>
		<div id="app">
			{{date | formatDate}}
		</div>
		<script type="text/javascript">
			var formatnum=function(num){
				return num <10?'0'+num:num;
			}
			new Vue(
			{
				el:'#app',
				data:{date:new Date()},
				filters:{
					formatDate:function(value){
						var year   = value.getFullYear();
						var month  = formatnum(value.getMonth()+1);
						var date   = formatnum(value.getDate());
						var hour   = formatnum(value.getHours());
						var mintue = formatnum(value.getMinutes());
						var seconds= formatnum(value.getSeconds());
						var utc= formatnum(value.getUTCFullYear());
						var utch= formatnum(value.getUTCHours());
						var utcm= formatnum(value.getUTCMinutes());
						var utcs= formatnum(value.getUTCSeconds());
						return year+"-"+month+"-"+date+" "+hour+":"+mintue+":"+seconds+"UTC:"+utc+":"+utch+":"+utcm+":"+utcs;
					}
				},
				mounted:function(){
					var _this = this;//此语句是保证_this和this具有相同的功能
					this.timer= setInterval(function (){
						_this.date = new Date();
					},1000
					);
				},
				beforeDestroy:function(){
					if(this.timer){
						clearInterval(this.timer);
					}
				}
			}
			);
			</script>
	</body>
</html>
